package groovy.database

import groovy.sql.*

class Util {
	private static final config = [
		driver: 'com.mysql.jdbc.Driver', 
		url: 'jdbc:mysql://localhost:3306/db', 
		user: 'root', 
		password: '2027372' ] 
	
	static execute(Closure closure) {
		Sql.withInstance(config) { sql ->
			closure.call(sql)
		}
	}
	
	static void main(def args) {
		Util.execute { Sql sql ->
			sql.eachRow("select * from user") { row -> println row }		
		}
	}
}
